package com.le.tester.javaThink.fifth.chapter24_ConcurrentProgramming;

/**
 * createTime：2021/8/23 11:39
 * description：Breakable
 */
public class Breakable {
    String id;
    private int failCount;

    public Breakable(String id, int failCount) {
        this.id = id;
        this.failCount = failCount;
    }

    @Override
    public String toString() {
        return "Breakable{" +
                "id='" + id + '\'' +
                ", failCount=" + failCount +
                '}';
    }

    public static Breakable work(Breakable b) {
        if (--b.failCount == 0) {
            System.out.println("Throwing Exception for " + b.id + "");
            throw new RuntimeException("Breakable_" + b.id + " failed");
        }
        System.out.println(b);
        return b;
    }

}
